udoDict = { 'attackDetector':
"""
opcode attackDetector, k, aiiiiii
    ainput, iresponse, iatk_thresh, imin_thresh, iRelThresh, iRelTime, irms_freq xin

; iresponse = response time in seconds (attack time)
; iatk_thresh = attack thresh in dB
; imin_thresh = minimum dB level before detecting attack (not true dB)
; iRelThresh = release threshold, as fraction of attack rms amplitude
; iRelTime = release delay time, time to wait after signal have dropped below threshold
; irms_freq = lp filter frequency for rms analysis, in cps

; detect signal attack
idelaytime = iresponse
ainput_dly delay ainput, idelaytime
krms rms ainput, irms_freq
krms_prev rms ainput_dly, irms_freq
krms_dB = dbfsamp(krms)
krms_prev_dB = dbfsamp(krms_prev)

; if current rms plus threshold is larger than previous rms
; and current rms is over minimum attack threshold
; set trig signal to current rms
ktrig init 0
ktrig = ((krms_dB + iatk_thresh > krms_prev_dB) && (krms_dB > imin_thresh) ? 1 : 0)

; detect signal rms below a certain percentage of the attack strength
kCurAtckRms samphold krms, ktrig
ksignalUnder = (krms < (kCurAtckRms * iRelThresh) ? 1 : 0)
ktrigUnder trigger ksignalUnder, 0.5, 0

; when signal below threshold, wait for irelease seconds
; if signal goes above threshold during release, don't release

; time stamping allow for delayed release trigger
ktime timeinsts
ktimeMarkOff init 0
ktimeMarkOff = (ktrigUnder > 0 ? ktime : ktimeMarkOff)
kDeltaOff = (ktime - ktimeMarkOff) * ksignalUnder
ktrigOff = (kDeltaOff > iRelTime ? ksignalUnder : 0)

; kState is 1 after attack and while signal is above threshold level
; kState goes to -1 when signal has dropped below threshold and has stayed low for iRelTime seconds
kState init 0
kState = (ktrig > 0 ? 1 : kState)
kState = (ktrigOff > 0 ? -1 : kState)

ktrigOut trigger kState, 0, 0
xout ktrigOut
endop

""",
        'didjeres':
"""
opcode didjeres, a, akkii
ain, klength, kd2, imode, inum xin

iamp = 1.+(sqrt(((imode+1)-inum)/imode))

ktrig changed kd2

if ktrig == 1 then
    kf1 = (inum - 0.5) * 340 / (4 * klength)
    kf2 = kf1 * ((1+(1+((4*(kd2-0.02))/(9.869585*0.02*((inum-0.5)^2))))^0.5))
    kf2 limit kf2, 10, sr/2.01
endif

kjit jspline .05, 8, 20
afilt resonx ain, kf2, 20*(1+kjit), 3, 1
afilt = afilt * iamp

xout afilt
endop

""",
        'harmonizer':
"""
opcode	harmonizer, a, akkk
ain, kdel, kfeed, ktrans	xin 

ainput	    init	0
kdelay    	port    kdel + 2, .005
kfeed	    port	kfeed, .01
knsemis   	port	ktrans, .01
kfract    	=       knsemis/12
kbasehz   	=       cpsoct(8)
knewhz    	=       cpsoct(8+kfract)
kratio    	=       knewhz/kbasehz
krate     	=       (kratio-1)/(kdelay/1000)

actl1     	phasor    	-krate
agate1    	tablei    	actl1, 5, 1, 0, 1
actl2     	phasor    	-krate, .5
agate2    	tablei    	actl2, 5, 1, 0, 1

asig1	vdelay	ainput, actl1*kdelay, 4000
asig2	vdelay	ainput, actl2*kdelay, 4000

asig1     	=         	asig1*agate1
asig2     	=         	asig2*agate2        

aout      	=         	asig1+asig2
aout        dcblock     aout
ainput   	=         	ain+aout*kfeed

	xout	aout
	endop 
	
""",
        'myGrain':
"""
opcode myGrain, a, kkkkkiii
kpos, kdur, kfreq, kdurmod, kposmod, iphase, itable, ienv xin
itabdur = nsamp(itable)
if itabdur != 0 igoto continue
itabdur tableng itable
continue:
apos upsamp (kpos + kposmod) * itabdur
adur upsamp kdur * kdurmod
apha phasor kfreq, iphase
aenv tab apha, ienv, 1
atrig = int(1-aenv)
aindex samphold apos, atrig
atrans samphold adur, atrig

aline = apha * atrans * sr + aindex
aline limit aline, 0, itabdur
ag tablei aline, itable, 0
aout = ag * aenv

xout aout
endop

""",
        'myGrain2':
"""
opcode myGrain2, aa, kkkkkiiii
kpos, kdur, kfreq, kdurmod, kposmod, iphase, itable, itable2, ienv xin
itabdur = nsamp(itable)
if itabdur != 0 igoto continue
itabdur tableng itable
continue:
apos upsamp (kpos + kposmod) * itabdur 
adur upsamp kdur * kdurmod
apha phasor kfreq, iphase
aenv tab apha, ienv, 1
atrig = int(1-aenv)
aindex samphold apos, atrig
atrans samphold adur, atrig

aline = apha * atrans * sr + aindex
aline limit aline, 0, itabdur
ag tablei aline, itable, 0
ad tablei aline, itable2, 0
aout1 = ag * aenv
aout2 = ad * aenv

xout aout1, aout2
endop

""",
        'myGrain3':
"""
opcode myGrain3, a, kkkkiii
kamp, kpos, kdur, kfreq, iphase, itable, ienv xin
itabdur = nsamp(itable)
if itabdur != 0 igoto continue
itabdur tableng itable
continue:
apos upsamp abs(kpos) * itabdur
adur upsamp kdur
apha phasor kfreq, iphase
aenv tab apha, ienv, 1
atrig = int(1-aenv)
aindex samphold apos, atrig
atrans samphold adur, atrig

aline = apha * atrans * sr + aindex
aline limit aline, 0 , itabdur
ag tablei aline, itable, 0
aout = ag * aenv * kamp

xout aout
endop

""",

        'recBuffer':
"""
opcode recBuffer, 0,akii

    setksmps 1

ap   init 0
kp   init 0

/* sig, trigger, ftable, dur */
ain,ktr,ifn,ilen xin 

iend = ilen*sr /* end point */
if ktr > 0 then
ktrig = 1        /* rec ON */
kp = 0
endif

if ktrig > 0 then  /* recording block */
    ap = kp
    if kp < iend then /* fill in the duration */
        tablew ain, ap, ifn 
    else            /* rec OFF */
       ktrig = 0   
    endif 
kp = kp + 1
endif             /* end recording block */

endop

""",
        'trigClearRev':
"""
opcode trigClearRev, k, k
ktrig xin

ilen tableng 6
isteps = int((10 * sr) / ksmps)
inc = ilen / isteps

kgate init 1
kswitch init 0
kpos init 0
kchanged changed ktrig
if kchanged == 1 && kgate == 1 then
kpos = 0
kswitch = 1
kgate = 0
endif

if kswitch == 1 then
kpos = kpos + inc
endif

if kpos >= (ilen-1) then
kpos = ilen-1
kswitch = 0
kgate = 1
endif

ksig tablei kpos, 6
xout 1 - (ksig * .25)
endop

""",
        'trigEnv':
"""
opcode trigEnv, k, kii
ktrig, idur, itab xin

ilen tableng itab
isteps = int((idur * sr) / ksmps)
inc = ilen / isteps

kgate init 1
kswitch init 0
kpos init 0
kchanged changed ktrig
if kchanged == 1 && kgate == 1 then
kpos = 0
kswitch = 1
kgate = 0
endif

if kswitch == 1 then
kpos = kpos + inc
endif

if kpos >= (ilen-1) then
kpos = ilen-1
kswitch = 0
kgate = 1
endif

ksig tablei kpos, itab
xout ksig
endop

""",
        'vocoder':
"""
opcode vocoder, a, aakkkpp

as1,as2,kmin,kmax,kq,ibnd,icnt  xin

if kmax < kmin then
ktmp = kmin
kmin = kmax
kmax = ktmp
endif

if kmin == 0 then 
kmin = 1
endif

if (icnt >= ibnd) goto bank
abnd   vocoder as1,as2,kmin,kmax,kq,ibnd,icnt+1

bank:
kfreq = kmin*(kmax/kmin)^((icnt-1)/(ibnd-1))
kbw = kfreq/kq
an  butterbp  as2, kfreq, kbw
an  butterbp  an, kfreq, kbw
as  butterbp  as1, kfreq, kbw
as  butterbp  as, kfreq, kbw

ao balance as, an

amix = ao + abnd

     xout amix

endop

""",
        'pulsar':
"""
opcode pulsar, a, kkiii
kfreq, kfrac, itab, ienv, iphase xin
setksmps 1
kind phasor kfreq, iphase

if kind < kfrac then
ktabind = kind * (1 / kfrac)
atabind upsamp ktabind
asig table3 atabind, itab, 1, 0, 1
kenv table3 ktabind, ienv, 1
asig = asig * kenv
else
asig = 0
endif

asig dcblock asig
    xout asig
endop

""",
        'tabsMod':
"""
opcode tabsMod, a, kkkii
kindx, kindy, kport, itabx, itaby xin
setksmps 1

itablenx tableng itabx
ifacx = nsamp(itabx) / itablenx

itableny tableng itaby
ifacy = nsamp(itaby) / itableny

kindx portk kindx, .1
kindy portk kindy, .1

aindx upsamp kindx
aindy upsamp kindy

ax table3 aindx * ifacx, itabx, 1, 0, 1
ay table3 aindy * ifacy, itaby, 1, 0, 1

asig = (ax * (ay/32000))
asig dcblock asig
    xout asig
endop

""",
        'discreetTableRead':
"""
opcode discreetTableRead, k, kkki
kinittrig, kspeed, kstep, itable xin
kcount init 0
if kinittrig == 1 then
kcount = 0
endif
klen table 0, itable
ktrig metro 1/kspeed
if ktrig == 1 then
kval table kcount+1, itable
kcount = (kcount + kstep) % klen
endif
xout kval
endop

"""
}